package org.yu.team2023.flashdays;


import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Items;
import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.registries.RegistryObject;
import org.yu.team2023.flashdays.item.*;
import org.yu.team2023.flashdays.registries.SimpleReg;

import static org.yu.team2023.flashdays.ModAttributes.*;

public class ModItems {
    private static final SimpleReg REG = FlashDays.getSimpleReg();

    public static final TreasureSets KHANS_THRONE = TreasureSets.create(
            "khans_throne",
            "银河可汗（一）",
            "银河可汗（二）",
            "银河可汗（三）",
            "银河可汗（四）",
            "KhansThrone",
            "可汗王座",
            "远程伤害增加40%",
            "击杀敌人后增加20%攻击和25%远程攻击，可叠加5层，持续一分钟，每次击杀刷新持续时间。",
            SetTiger.byAttribute2("khans_throne", ModAttributes.RANGED_DAMAGE, 40, AttributeModifier.Operation.ADDITION)
    );

    public static final TreasureSets LAST_BAOL = TreasureSets.create(
            "last_baol",
            "巴奥（一）",
            "巴奥（二）",
            "巴奥（三）",
            "巴奥（四）",
            "LastBaol",
            "最后的巴奥",
            "生命上限+25%",
            "血量低于10%时回复40%最大生命值，并进入1分钟的冷却。",
            SetTiger.byAttribute2("last_baol", () -> Attributes.MAX_HEALTH, 0.25, AttributeModifier.Operation.MULTIPLY_BASE)
    );

    public static final TreasureSets GALATRON = TreasureSets.create(
            "galatron",
            "银河之星（一）",
            "银河之星（二）",
            "银河之星（三）",
            "银河之星（四）",
            "Galatron",
            "银河之星",
            "幸运+2",
            "当周围10格内存在队友时，所有友方攻击增加10%，攻速增加10%，暴击率增加25%。",
            SetTiger.byAttribute2("galatron", () -> Attributes.LUCK, 2, AttributeModifier.Operation.ADDITION)
    );
    public static final TreasureSets IRASSIAN = TreasureSets.create(
            "pox_sample",
            "贾沃疹（一）",
            "贾沃疹（二）",
            "贾沃疹（三）",
            "贾沃疹（四）",
            "Irassian ",
            "贾沃疹样本",
            "弱点特攻+20%",
            "降低周围敌人20%伤害抗性。攻击受到负面状态的敌人时，伤害提高25%。",
            new SetTiger() {
                @Override
                public void onFormedTwo(Player player) {
                    ModUtil.addAttributeModifier(player, ModAttributes.WEAKNESS_SPECIAL_ATTACK, "pox_sample2", 20, AttributeModifier.Operation.ADDITION);
                }

                @Override
                public void onUnformedTwo(Player player) {
                    ModUtil.removeAttributeModifier(player, ModAttributes.WEAKNESS_SPECIAL_ATTACK, "pox_sample2");
                }

                @Override
                public void onFormedFour(Player player) {
                    ModUtil.addAttributeModifier(player, ModAttributes.WEAKNESS_SPECIAL_ATTACK, "pox_sample4", 25, AttributeModifier.Operation.ADDITION);
                }

                @Override
                public void onUnformedFour(Player player) {
                    ModUtil.removeAttributeModifier(player, ModAttributes.WEAKNESS_SPECIAL_ATTACK, "pox_sample4");
                }
            }
    );
    public static final TreasureSets CYBREX = TreasureSets.create(
            "war_forge",
            "赛博勒克斯（一）",
            "赛博勒克斯（二）",
            "赛博勒克斯（三）",
            "赛博勒克斯（四）",
            "Cybrex",
            "赛博勒克斯兵工厂",
            "攻击力+50%",
            "每次攻击时进行一次判定，有20%几率增加50%伤害，49%几率无事发生，15%几率回复10%生命，5%几率消耗10%生命，1%几率使得自身濒死，并使伤害提升佩戴者最大生命值的10倍。",
            SetTiger.byAttribute2("war_forge", () -> Attributes.ATTACK_DAMAGE, 0.2, AttributeModifier.Operation.MULTIPLY_BASE)
    );
    public static final TreasureSets ZRO_CRYSTAL = TreasureSets.create(
            "zro_crystal",
            "灵能档案（一）",
            "灵能档案（二）",
            "灵能档案（三）",
            "灵能档案（四）",
            "ZroCrystal",
            "灵能档案",
            "治疗效果提升20%",
            "当自身受到治疗时，为范围内的玩家治疗，数值为当次治疗的10%。",
            SetTiger.byAttribute2("zro_crystal", RECOVER_EFFECT, 20, AttributeModifier.Operation.ADDITION)
    );
    public static final TreasureSets WARMONGER = TreasureSets.create(
            "warmonger",
            "战狂（一）",
            "战狂（二）",
            "战狂（三）",
            "战狂（四）",
            "Warmonger",
            "无惧的战狂",
            "物品使用时间缩减40%",
            "每次攻击增加自己7%攻速和7%攻击力和4.5%免伤，可以叠加10层，持续20秒，每次获得层数刷新持续时间。",
            SetTiger.byAttribute2("warmonger", ModAttributes.USE_SPEED_UP, 40, AttributeModifier.Operation.ADDITION)
    );
    public static final TreasureSets BLOODTHIRSTY = TreasureSets.create(
            "bloodthirsty",
            "嗜血（一）",
            "嗜血（二）",
            "嗜血（三）",
            "嗜血（四）",
            "Bloodthirsty",
            "生命渴望",
            "生命窃取+15%",
            "生命窃取+30%，攻击减少自身15%最大生命值并获得3.5秒“血渴”，使伤害提升最大生命值的10%。当“血渴”存在时攻击将不会消耗生命值。",
            new SetTiger() {
                @Override
                public void onFormedTwo(Player player) {
                    ModUtil.addAttributeModifier(player, HEALTH_STEAL, "bloodthirsty", 15, AttributeModifier.Operation.ADDITION);
                }

                @Override
                public void onUnformedTwo(Player player) {
                    ModUtil.removeAttributeModifier(player, HEALTH_STEAL, "bloodthirsty");
                }

                @Override
                public void onFormedFour(Player player) {
                    ModUtil.addAttributeModifier(player, HEALTH_STEAL, "bloodthirsty4", 30, AttributeModifier.Operation.ADDITION);
                }

                @Override
                public void onUnformedFour(Player player) {
                    ModUtil.removeAttributeModifier(player, HEALTH_STEAL, "bloodthirsty4");
                }
            }
    );
    public static final TreasureSets DILLER = TreasureSets.createSimple(
            "diller",
            "莳者的复明义眼",
            "莳者的机巧木手",
            "莳者的承露羽衣",
            "莳者的天人丝履",
            "Diller",
            "宝命长存的莳者",
            "生命上限提高12%。",
            "当装备者受到攻击或被我方目标消耗生命值后，暴击率提高8%，持续10秒，该效果最多叠加2层。",
            new SetTiger() {
                @Override
                public void onFormedTwo(Player player) {
                    ModUtil.addAttributeModifier(player, () -> Attributes.MAX_HEALTH, "diller", 0.15, AttributeModifier.Operation.MULTIPLY_BASE);
                }

                @Override
                public void onUnformedTwo(Player player) {
                    ModUtil.removeAttributeModifier(player, () -> Attributes.MAX_HEALTH, "diller");
                }

                @Override
                public void onFormedFour(Player player) {
                }

                @Override
                public void onUnformedFour(Player player) {
                }
            }
    );
    public static final TreasureSets MMXB = TreasureSets.create(
            "mmxb",
            "慢慢想吧（1）",
            "慢慢想吧（2）",
            "慢慢想吧（3）",
            "慢慢想吧（4）",
            "mmxb",
            "小枫说：慢慢想吧。",
            "生命上限提高20%。",
            "生命上限提高180%,减少100%暴击率。",
            new SetTiger() {
                @Override
                public void onFormedTwo(Player player) {
                    ModUtil.addAttributeModifier(player, () -> Attributes.MAX_HEALTH, "mmxb", 0.2, AttributeModifier.Operation.MULTIPLY_BASE);
                }

                @Override
                public void onUnformedTwo(Player player) {
                    ModUtil.removeAttributeModifier(player, () -> Attributes.MAX_HEALTH, "mmxb");
                }

                @Override
                public void onFormedFour(Player player) {
                    ModUtil.addAttributeModifier(player, () -> Attributes.MAX_HEALTH, "mmxb4", 1.8, AttributeModifier.Operation.MULTIPLY_BASE);
                    ModUtil.addAttributeModifier(player, CRIT, "mmxb4c", -100, AttributeModifier.Operation.ADDITION);

                }

                @Override
                public void onUnformedFour(Player player) {
                    ModUtil.removeAttributeModifier(player, () -> Attributes.MAX_HEALTH, "mmxb4");
                    ModUtil.removeAttributeModifier(player, CRIT, "mmxb4c");
                }
            }
    );
    public static final RegistryObject<DebugStick> DEBUG_STICK = REG.item("debug_stick", DebugStick::new).lang("调试棍").copyModel(() -> Items.DEBUG_STICK).build();
    public static final RegistryObject<ForgeSpawnEggItem> DAMAGE_HUMAN_SPAWN_EGG = REG.item("damage_human_spawn_egg", (p) -> new ForgeSpawnEggItem(ModEntities.DAMAGE_HUMAN, 0, 0x245, p)).lang("假人蛋").copyModel(() -> Items.SHEEP_SPAWN_EGG).build();

    public static final RegistryObject<TreasureUpgradeItem> UPGRADE_SMALL = TreasureUpgradeItem.create(REG, "treasure_upgrade_small", "万象结晶（小）", 10);
    public static final RegistryObject<TreasureUpgradeItem> UPGRADE_MID = TreasureUpgradeItem.create(REG, "treasure_upgrade_mid", "万象结晶（中）", 50);
    public static final RegistryObject<TreasureUpgradeItem> UPGRADE_BIG = TreasureUpgradeItem.create(REG, "treasure_upgrade_big", "万象结晶（大）", 200);

    public static void init() {
        REG.lang("tip.secondEffect", "当穿戴两件时：")
                .lang("tip.treasure.quality.COMMON", "普通")
                .lang("tip.treasure.quality.UNCOMMON", "一般")
                .lang("tip.treasure.quality.RARE", "稀有")
                .lang("tip.treasure.quality.EPIC", "史诗")
                .lang("tip.box.great", "极品！必出史诗！")
                .lang("tip.fourthEffect", "当穿戴四件时：")
                .lang("tip.treasure_box", "使用后获得三件随机品质的【%s】遗珍")
                .lang("curios.identifier.treasure1", "遗珍（一）")
                .lang("curios.identifier.treasure2", "遗珍（二）")
                .lang("curios.identifier.treasure3", "遗珍（三）")
                .lang("curios.identifier.treasure4", "遗珍（四）")
                .lang("msg.flashdays.treasure.upgrade.failed", "升级失败，主手物品无遗珍数据")
                .lang("tab.flashdays.title", "闪光日")
                .lang("msg.flashdays.cyberlexer.hit", "鸿运当头！漂亮的一击！")
                .lang("tip.flashdays.onlyshow", "[仅供展示]")
                .lang("tip.flashdays.treasureMain", "主词条")
                .lang("tip.flashdays.treasureAdditions", "副词条")
                .lang("death.attack.flashdays.AdditionAttack", "%s死于追击。")
                .lang("death.attack.flashdays.Bleed", "%s血流干了。")
                .lang("death.attack.flashdays.Reflexive", "%s被自己打死啦！")
                .lang("damage.POSITIVE_INFINITY", "无限")
                .lang("msg.Fire", "燃烧")
                .lang("msg.Freeze", "冻结")
                .lang("tip.flashdays.not_upgradeable", "不可升级")
                .lang("tip.flashdays.upgradeable", "升级")
                .lang("tip.flashdays.upgradeCount", "强化等级：%s")
                .lang("tip.flashdays.shift_show_set", "<按下Shift查看套装效果>")
                .lang("tip.flashdays.treasure_upgrade_xp", "提供%s遗珍经验")
                .lang("tips.flashdays.treasure_output_not_empty", "错误：输出槽不为空")
                .lang("tips.flashdays.upgrade_progress", "%s/%s")
                .lang("tips.flashdays.upgrade_progress_max", "已满级")
                .lang("flashdays.desc.skill_item.desc", "试用卡片后，你将学会以下技能，并遗忘其他技能")
                .lang("flashdays.desc.skill_item", "扮演卡：%s")
                .lang("tip.flashdays.windbow", "射出箭后，箭矢将在7tick后消失，当箭矢命中目标或者消失时，在自身位置生成一个半径25格，持续25s的风暴之眼，当风暴之眼存在时，将会持续牵引范围内生物至其中心位置。");
    }

}
